﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
       

        static void Main(string[] args)
        {
            //收银台
            //组件购物车商品
            List<ShoppingCart> shoppingCarts = new List<ShoppingCart>();
            //假设放两种商品BuyDrinking
            //清空购物车，结算
            //创建线程——总价计算
            //启动线程

            Console.WriteLine("按任意键继续......");
            Console.ReadKey();
        }
        //购物车总结算——方法
        static decimal SumPrice(List<ShoppingCart> spg)
        {
            decimal Monry = 0;
            decimal Monry1;
            for(int i = 0;i<spg.Count;i++)
            {
                Monry1 = spg[i].Goods.Price * spg[i].Number;
                Monry += Monry1;
                Monry1 = 0;
            }
            return Monry;
        }
        //购买3瓶可口可乐
        static ShoppingCart BuyDrinking(int number)
        {
            SuperMarket market = new SuperMarket();
            ShoppingCart shoppingCart = new ShoppingCart()
            {
                Goods = market.goods.Where(x => x.Name.Contains("可口可乐")).FirstOrDefault(),
                Number = number
                
            };
            return shoppingCart;

        }
        
        
        class SuperMarket
        {
            public List<Goods> goods;//商品对象
            public SuperMarket()
            {
                goods = new List<Goods>()
                {
                      new Goods (){Id ="noodles01",Name ="汤达人",Price =20.00M,Unit="组"},
                      new Goods (){Id ="coffee01",Name ="ill中焙",Price =90.00M,Unit="罐"},
                      new Goods (){Id ="chocolate01",Name ="Beryl's 80%",Price =19.9M,Unit="块"},
                      new Goods (){Id ="",Name ="",Price =3.5M,Unit="瓶"}

                };
            }
        }

        //购物车
        class ShoppingCart
        {
            public Goods Goods {get;set;}//商品
            public int Number { get; set; }//数量
        }
        class Goods
        {
            public string Id { get; set; }//商品编号
            public string Name { get; set; }
            public decimal Price { get; set; }//价格
            public string Unit { get; set; }
        }
    }
}
